package com.example.sellersale.controller;

import com.example.sellersale.entity.CartInfo;
import com.example.sellersale.server.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class CartInfoController {
    @Autowired
    private CartService cartService;

    @PostMapping("/addCart")
    public CartInfo addCart(CartInfo cartInfo){
        return cartService.addCartInfo(cartInfo);
    }

    /**
     * 删除购物车
     * @param cartId
     * @return
     */
    @DeleteMapping("/delCart")
    public Boolean delCartInfo(String cartId){
        return cartService.delCartInfo(cartId);
    }
    /**
     * 修改购物车信息
     * @param cartInfo
     * @return
     */
    @PostMapping("/editCart")
    public CartInfo updateCartInfo(CartInfo cartInfo){
        return  cartService.editCartInfo(cartInfo);
    }
    @GetMapping("/userCart")
    public List<CartInfo> userCart(String uId){
        return cartService.userCart(uId);
    }

}
